package com.newblog.action;

import java.sql.Connection;

public abstract class DBConnection {
	private static DBConnection instance = null;
	
	private static Object initObj = new Object();
	
	public static DBConnection getInstance(){
		if(instance==null)
		  synchronized(initObj){
			try{ 
			   String DBPoolImplement = AppConfig.getProperty(AppContant.DB_CONNECTION_POOL);
			   instance = (DBConnection)Class.forName(DBPoolImplement).newInstance();
			}
			catch(ClassNotFoundException e){
				e.printStackTrace();
			}
			catch(IllegalAccessException e){
				e.printStackTrace();
			}
			catch(InstantiationException e){
				e.printStackTrace();
			}
		  }
		return instance;
	}
	public abstract void Init();
	
	public abstract Connection getConnection();
	
	public abstract void releaseConnection(Connection conn);
	
	public abstract void releaseAllConnection();

}
